{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 批量自动生成部分thor规则\n",
    "步骤:\n",
    "* 1.rsp填写为自己微信账单真实支付的json\n",
    "* 2.此脚本内createstr 替换为要生成的日期和费用\n",
    "* 3.将替换结果的规则粘贴进thor任务里"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json,time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 真实支付结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "rsp = '{\"ret_code\":0,\"statistic\":[{\"year\":2022,\"month\":1,\"receive_fee\":30000,\"pay_fee\":66250,\"fee_unit\":\"￥\",\"userroll_count\":25},{\"year\":2021,\"month\":12,\"receive_fee\":0,\"pay_fee\":50810,\"fee_unit\":\"￥\",\"userroll_count\":35}],\"record\":[{\"bill_id\":\"a3fdd46120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710122010500084342337949524694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1641348515,\"fee\":800,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10001071012022010501169102419635\"},{\"bill_id\":\"c2b3d36120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990122010400084341835792383694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1641264066,\"fee\":1200,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012022010401172480445533\"},{\"bill_id\":\"7e10d36120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990122010300084342325754400694\",\"title\":\"扫二维码付款-给你好\",\"timestamp\":1641222270,\"fee\":2500,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012022010301071384549519\"},{\"bill_id\":\"9895d16120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990122010200084341322058431694\",\"title\":\"扫二维码付款-给戈壁滩王子\",\"timestamp\":1641125272,\"fee\":1250,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012022010201263474213645\"},{\"bill_id\":\"2b11d06120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710122010100084341809006539694\",\"title\":\"扫二维码付款-给huangmao\",\"timestamp\":1641025835,\"fee\":1000,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10001071012022010101991778993579\"},{\"bill_id\":\"e6bbcd6120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121123000084342382275134694\",\"title\":\"扫二维码付款-给🍉\",\"timestamp\":1640872934,\"fee\":2450,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021123001122440482583\"},{\"bill_id\":\"472bcd6120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121123000084341576140600694\",\"title\":\"扫二维码付款-给符万荣\",\"timestamp\":1640835911,\"fee\":2050,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021123001921776050581\"},{\"bill_id\":\"961ecd6120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710121123000084342775518146694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1640832662,\"fee\":800,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10001071012021123001383316504617\"},{\"bill_id\":\"f6cbcb6120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710121122900084341373143653694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1640745974,\"fee\":800,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10001071012021122901655981142500\"},{\"bill_id\":\"9827cb6120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122800084341221409842694\",\"title\":\"扫二维码付款-给余生请多指教\",\"timestamp\":1640703896,\"fee\":1150,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122801143748288622\"},{\"bill_id\":\"b77bca6120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122800084342756159163694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1640659895,\"fee\":400,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122801964382059584\"},{\"bill_id\":\"cf2cc96120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122700084341054355919694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1640574159,\"fee\":300,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122701858331096606\"},{\"bill_id\":\"2b49c76120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122600084341534544862694\",\"title\":\"扫二维码付款-给老婆的变形金刚\",\"timestamp\":1640450347,\"fee\":2600,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122601709802169530\"},{\"bill_id\":\"63dcc56120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710121122400084342324813581694\",\"title\":\"扫二维码付款-给A大米7076\",\"timestamp\":1640356963,\"fee\":1000,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/wxpaylogo.qpic.cn\\/wxpaylogo\\/PiajxSqBRaELcSRqecBN21moKWlUf80SJdmMss5oMJrAneD0z7VRzcQ\\/132\",\"out_trade_no\":\"10001071012021122401740824319571\"},{\"bill_id\":\"78c7c56120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710121122400084341031667735694\",\"title\":\"扫二维码付款-给磊\",\"timestamp\":1640351608,\"fee\":1000,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10001071012021122401073399198596\"},{\"bill_id\":\"5d3fc56120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122400084341326028687694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1640316765,\"fee\":600,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122401303496680565\"},{\"bill_id\":\"a211c46120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122300084341316473895694\",\"title\":\"扫二维码付款-给小杨果业\",\"timestamp\":1640239522,\"fee\":1600,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122301756010134626\"},{\"bill_id\":\"4f84c26120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100010710121122200084342796566205694\",\"title\":\"扫二维码付款-给沫然和田玉\",\"timestamp\":1640137807,\"fee\":800,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10001071012021122201335188245520\"},{\"bill_id\":\"b7e6c16120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122100084342394284061694\",\"title\":\"扫二维码付款-给金山谷蔬菜百货超市\",\"timestamp\":1640097463,\"fee\":900,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/wxpaylogo.qpic.cn\\/wxpaylogo\\/PiajxSqBRaELFK5zvTSluGUwX7ubMGB2128cf8PxibuFCHRzTO7GseQg\\/132\",\"out_trade_no\":\"10000499012021122101604946551531\"},{\"bill_id\":\"7be6c16120a10700BgAACOcLcZ2Rw1w+4Q==\",\"trans_id\":\"100004990121122100084341001529592694\",\"title\":\"扫二维码付款-给新疆商务旅游包车轩亮13209903030\",\"timestamp\":1640097403,\"fee\":2500,\"fee_type\":\"CNY\",\"fee_attr\":\"negtive\",\"current_state\":\"\",\"current_state_type\":\"neutral\",\"bill_type\":38,\"icon_url\":\"https:\\/\\/res.wx.qq.com\\/a\\/wx_fed\\/wxpay_common_assets\\/res\\/tradingrecord\\/receivable-7f0f753770.png\",\"out_trade_no\":\"10000499012021122101678971844516\"}],\"total\":20,\"last_bill_id\":\"7be6c16120a10700BgAACOcLcZ2Rw1w+4Q==\",\"last_bill_type\":38,\"last_trans_id\":\"100004990121122100084341001529592694\",\"last_create_time\":1640097403,\"is_over\":false,\"cold_data_limit\":1,\"banner\":{\"content\":\"\"}}'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataobj = json.loads(rsp)\n",
    "realpayobj = json.loads(rsp)['record']\n",
    "rspobj = json.loads(rsp)['record']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(rspobj)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 微信支付-我的账单-账单明细-列表\n",
    "更换timestamp和fee,填写格式为[['2022-01-22 19:23:24',800],[t2,fee2]],转换格式为[{\"timestamp\":123123,\"fee\":800}]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'timestamp': '2022-01-20 10:16:01', 'fee': 234600}, {'timestamp': '2022-01-19 22:11:41', 'fee': 298600}, {'timestamp': '2022-01-18 20:12:34', 'fee': 759000}, {'timestamp': '2022-01-17 12:25:11', 'fee': 84600}, {'timestamp': '2022-01-16 15:10:27', 'fee': 118500}]\n"
     ]
    }
   ],
   "source": [
    "createstr = '[{\"timestamp\":\"2022-01-20 10:16:01\",\"fee\":234600},{\"timestamp\":\"2022-01-19 22:11:41\",\"fee\":298600},{\"timestamp\":\"2022-01-18 20:12:34\",\"fee\":759000},{\"timestamp\":\"2022-01-17 12:25:11\",\"fee\":84600},{\"timestamp\":\"2022-01-16 15:10:27\",\"fee\":118500}]'\n",
    "newobj = json.loads(createstr)\n",
    "print(newobj)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'timestamp': 1642644961, 'fee': 234600}, {'timestamp': 1642601501, 'fee': 298600}, {'timestamp': 1642507954, 'fee': 759000}, {'timestamp': 1642393511, 'fee': 84600}, {'timestamp': 1642317027, 'fee': 118500}]\n"
     ]
    }
   ],
   "source": [
    "for k in range(len(newobj)):\n",
    "    str_time = str(newobj[k]['timestamp'])\n",
    "    timestamp = int(time.mktime(time.strptime(str_time, '%Y-%m-%d %H:%M:%S')))\n",
    "    newobj[k]['timestamp'] = timestamp\n",
    "    \n",
    "print(newobj)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "pay_fee = 0\n",
    "for i in range(len(rspobj)):\n",
    "    if i<len(newobj):\n",
    "        rspobj[i]['timestamp'] = newobj[i]['timestamp']\n",
    "        rspobj[i]['fee'] = newobj[i]['fee']\n",
    "    pay_fee = pay_fee + rspobj[i]['fee']\n",
    "\n",
    "dataobj['record'] = rspobj\n",
    "##此处替换总支付\n",
    "#dataobj['statistic'][0]['pay_fee'] = pay_fee\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"ret_code\": 0, \"statistic\": [{\"year\": 2022, \"month\": 1, \"receive_fee\": 30000, \"pay_fee\": 66250, \"fee_unit\": \"\\uffe5\", \"userroll_count\": 25}, {\"year\": 2021, \"month\": 12, \"receive_fee\": 0, \"pay_fee\": 50810, \"fee_unit\": \"\\uffe5\", \"userroll_count\": 35}], \"record\": [{\"bill_id\": \"a3fdd46120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710122010500084342337949524694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1642644961, \"fee\": 234600, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10001071012022010501169102419635\"}, {\"bill_id\": \"c2b3d36120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990122010400084341835792383694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1642601501, \"fee\": 298600, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012022010401172480445533\"}, {\"bill_id\": \"7e10d36120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990122010300084342325754400694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u4f60\\u597d\", \"timestamp\": 1642507954, \"fee\": 759000, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012022010301071384549519\"}, {\"bill_id\": \"9895d16120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990122010200084341322058431694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6208\\u58c1\\u6ee9\\u738b\\u5b50\", \"timestamp\": 1642393511, \"fee\": 84600, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012022010201263474213645\"}, {\"bill_id\": \"2b11d06120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710122010100084341809006539694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9huangmao\", \"timestamp\": 1642317027, \"fee\": 118500, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10001071012022010101991778993579\"}, {\"bill_id\": \"e6bbcd6120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121123000084342382275134694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\ud83c\\udf49\", \"timestamp\": 1640872934, \"fee\": 2450, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021123001122440482583\"}, {\"bill_id\": \"472bcd6120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121123000084341576140600694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u7b26\\u4e07\\u8363\", \"timestamp\": 1640835911, \"fee\": 2050, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021123001921776050581\"}, {\"bill_id\": \"961ecd6120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710121123000084342775518146694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1640832662, \"fee\": 800, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10001071012021123001383316504617\"}, {\"bill_id\": \"f6cbcb6120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710121122900084341373143653694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1640745974, \"fee\": 800, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10001071012021122901655981142500\"}, {\"bill_id\": \"9827cb6120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122800084341221409842694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u4f59\\u751f\\u8bf7\\u591a\\u6307\\u6559\", \"timestamp\": 1640703896, \"fee\": 1150, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122801143748288622\"}, {\"bill_id\": \"b77bca6120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122800084342756159163694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1640659895, \"fee\": 400, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122801964382059584\"}, {\"bill_id\": \"cf2cc96120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122700084341054355919694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1640574159, \"fee\": 300, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122701858331096606\"}, {\"bill_id\": \"2b49c76120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122600084341534544862694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u8001\\u5a46\\u7684\\u53d8\\u5f62\\u91d1\\u521a\", \"timestamp\": 1640450347, \"fee\": 2600, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122601709802169530\"}, {\"bill_id\": \"63dcc56120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710121122400084342324813581694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9A\\u5927\\u7c737076\", \"timestamp\": 1640356963, \"fee\": 1000, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://wxpaylogo.qpic.cn/wxpaylogo/PiajxSqBRaELcSRqecBN21moKWlUf80SJdmMss5oMJrAneD0z7VRzcQ/132\", \"out_trade_no\": \"10001071012021122401740824319571\"}, {\"bill_id\": \"78c7c56120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710121122400084341031667735694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u78ca\", \"timestamp\": 1640351608, \"fee\": 1000, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10001071012021122401073399198596\"}, {\"bill_id\": \"5d3fc56120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122400084341326028687694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1640316765, \"fee\": 600, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122401303496680565\"}, {\"bill_id\": \"a211c46120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122300084341316473895694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u5c0f\\u6768\\u679c\\u4e1a\", \"timestamp\": 1640239522, \"fee\": 1600, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122301756010134626\"}, {\"bill_id\": \"4f84c26120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100010710121122200084342796566205694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u6cab\\u7136\\u548c\\u7530\\u7389\", \"timestamp\": 1640137807, \"fee\": 800, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10001071012021122201335188245520\"}, {\"bill_id\": \"b7e6c16120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122100084342394284061694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u91d1\\u5c71\\u8c37\\u852c\\u83dc\\u767e\\u8d27\\u8d85\\u5e02\", \"timestamp\": 1640097463, \"fee\": 900, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://wxpaylogo.qpic.cn/wxpaylogo/PiajxSqBRaELFK5zvTSluGUwX7ubMGB2128cf8PxibuFCHRzTO7GseQg/132\", \"out_trade_no\": \"10000499012021122101604946551531\"}, {\"bill_id\": \"7be6c16120a10700BgAACOcLcZ2Rw1w+4Q==\", \"trans_id\": \"100004990121122100084341001529592694\", \"title\": \"\\u626b\\u4e8c\\u7ef4\\u7801\\u4ed8\\u6b3e-\\u7ed9\\u65b0\\u7586\\u5546\\u52a1\\u65c5\\u6e38\\u5305\\u8f66\\u8f69\\u4eae13209903030\", \"timestamp\": 1640097403, \"fee\": 2500, \"fee_type\": \"CNY\", \"fee_attr\": \"negtive\", \"current_state\": \"\", \"current_state_type\": \"neutral\", \"bill_type\": 38, \"icon_url\": \"https://res.wx.qq.com/a/wx_fed/wxpay_common_assets/res/tradingrecord/receivable-7f0f753770.png\", \"out_trade_no\": \"10000499012021122101678971844516\"}], \"total\": 20, \"last_bill_id\": \"7be6c16120a10700BgAACOcLcZ2Rw1w+4Q==\", \"last_bill_type\": 38, \"last_trans_id\": \"100004990121122100084341001529592694\", \"last_create_time\": 1640097403, \"is_over\": false, \"cold_data_limit\": 1, \"banner\": {\"content\": \"\"}}\n"
     ]
    }
   ],
   "source": [
    "print(json.dumps(dataobj))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 微信支付-我的账单-账单明细-支出与收入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "allstatistic = '[{\"year\":2022,\"month\":1,\"receive_fee\":30000,\"pay_fee\":662500000,\"fee_unit\":\"￥\",\"userroll_count\":25},{\"year\":2021,\"month\":12,\"receive_fee\":2340,\"pay_fee\":50810000,\"fee_unit\":\"￥\",\"userroll_count\":35}]'\n",
    "\n",
    "statistic_obj = json.loads(allstatistic)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataobj['statistic'] = statistic_obj\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(json.dumps(dataobj))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 微信支付-我的账单-账单明细-点击某条进入详细账单\n",
    "增加所有详细账单的Thor规则,需要用到真实支付时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "^@rsp.bodyText \"\"name\":\"1641348515\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1642644961\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1641264066\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1642601501\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1641222270\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1642507954\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1641125272\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1642393511\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1641025835\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1642317027\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640872934\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640872934\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640835911\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640835911\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640832662\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640832662\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640745974\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640745974\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640703896\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640703896\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640659895\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640659895\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640574159\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640574159\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640450347\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640450347\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640356963\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640356963\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640351608\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640351608\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640316765\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640316765\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640239522\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640239522\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640137807\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640137807\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640097463\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640097463\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "^@rsp.bodyText \"\"name\":\"1640097403\",\"actionsheet\":\\[\\],\"is_timestamp\":true\" \"\"name\":\"1640097403\",\"actionsheet\":[],\"is_timestamp\":true\" \n",
      "\n",
      "^@rsp.bodyText \"\"fee\":\"-8.00\"\" \"\"fee\":\"-2346.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-12.00\"\" \"\"fee\":\"-2986.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-25.00\"\" \"\"fee\":\"-7590.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-12.50\"\" \"\"fee\":\"-846.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-10.00\"\" \"\"fee\":\"-1185.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-24.50\"\" \"\"fee\":\"-24.50\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-20.50\"\" \"\"fee\":\"-20.50\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-8.00\"\" \"\"fee\":\"-8.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-8.00\"\" \"\"fee\":\"-8.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-11.50\"\" \"\"fee\":\"-11.50\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-4.00\"\" \"\"fee\":\"-4.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-3.00\"\" \"\"fee\":\"-3.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-26.00\"\" \"\"fee\":\"-26.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-10.00\"\" \"\"fee\":\"-10.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-10.00\"\" \"\"fee\":\"-10.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-6.00\"\" \"\"fee\":\"-6.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-16.00\"\" \"\"fee\":\"-16.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-8.00\"\" \"\"fee\":\"-8.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-9.00\"\" \"\"fee\":\"-9.00\"\" \n",
      "^@rsp.bodyText \"\"fee\":\"-25.00\"\" \"\"fee\":\"-25.00\"\" \n",
      "\n"
     ]
    }
   ],
   "source": [
    "#thorstr = '^@rsp.bodyText \"\"name\":\"\\d+\",\\\"actionsheet\\\\\":\\[\\],\"is_timestamp\":true\" \"\\\"name\\\":\\\"${paytime}\\\",\\\"actionsheet\\\":[],\\\"is_timestamp\\\":true\"'\n",
    "# ^@rsp.bodyText \"\"fee\":\".*?\"\" \"\\\"fee\\\":\\\"${paynum}\\\"\"\n",
    "\n",
    "thortimestr = ''\n",
    "thorfeestr = ''\n",
    "for t in range(len(realpayobj)):\n",
    "    thortimestr += '^@rsp.bodyText \"\"name\":\"'+ str(realpayobj[t]['timestamp']) + '\",\\\"actionsheet\\\":\\[\\],\"is_timestamp\":true\" \"\\\"name\\\":\\\"' + str(rspobj[t]['timestamp']) + '\\\",\\\"actionsheet\\\":[],\\\"is_timestamp\\\":true\" \\n'\n",
    "    oldf = realpayobj[t]['fee']/100\n",
    "    oldfee = ('%.2f' %oldf)\n",
    "    newf = rspobj[t]['fee']/100\n",
    "    newfee = ('%.2f' %newf)\n",
    "    thorfeestr += '^@rsp.bodyText \"\"fee\":\"-' +oldfee  + '\"\" \"\\\"fee\\\":\\\"-' + newfee + '\\\"\" \\n'\n",
    "print(thortimestr)\n",
    "\n",
    "print(thorfeestr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "800.45\n",
      "8.00\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "xx = re.findall(r\"\\d{1,}?\\.\\d{2}\",str(80045/100))[0]\n",
    "print(xx)\n",
    "\n",
    "xxx = 800/100\n",
    "r = ('%.2f' %xxx)\n",
    "print(r)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
